Skip to content

Examples: use the converters the API spec documents - #125

Merged
tomasr78 merged 2 commits into
mainfrom
examples-documented-converters
Nov 9, 2026
Merged

tomasr78 merged 2 commits into
mainfrom
examples-documented-converters

Conversation

@tomasr78

@tomasr78 tomasr78 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Three examples call converters that the production API spec (https://v2.convertapi.com/info/openapi, 332 paths on 2026-11-09) does not list. They still convert today, but developers copy these examples and the how-to guides on convertapi.com reuse them, so they should call documented converters. This is the Node part of what ConvertAPI/convertapi-library-dotnet#86 does for .NET.

Example Before After
convert_url_to_pdf.js web -> pdf, comment links /web-to-pdf html -> pdf (parameters), same Url and FileName; comment links https://www.convertapi.com/html-to-pdf
get_result_file_stream.js same as above same as above
conversion_chaining.js any -> zip: with no source format the library sends every zip conversion to any file -> zip (parameters): 'file' passed as the source format, same Files

https://www.convertapi.com/web-to-pdf is not in the site's sitemap; https://www.convertapi.com/html-to-pdf is. The other examples already call documented converters. CI runs the examples against staging, which served the same spec as production on 2026-11-09 (4,729,541 bytes).

Verified against production (2026-11-09)

Node 24.20.0, npm ci && npm run build, then node examples/<name>.js from the repo root, once on main (a402bd7) and once on this branch, with the token in API_TOKEN. The [trace] lines come from a --require preload that prints each request's path; they are not part of the examples' output. <tmp> is os.tmpdir().

conversion_chaining.js on this branch:

Converting PDF to JPG and compressing result files with ZIP

[trace] POST v2.convertapi.com/upload -> HTTP 200
[trace] POST v2.convertapi.com/convert/pdf/to/jpg -> HTTP 200
[trace] POST v2.convertapi.com/convert/file/to/zip -> HTTP 200
Files saved to
<tmp>/test.zip

On main the output is the same except the third request, POST v2.convertapi.com/convert/any/to/zip. Both runs saved a 775,249-byte test.zip with test.jpg to test-6.jpg; the JPGs are byte-identical before and after.

convert_url_to_pdf.js on this branch (on main the request was /convert/web/to/pdf, the rest the same):

[trace] POST v2.convertapi.com/convert/html/to/pdf -> HTTP 200
The web page PDF saved to
<tmp>/web-example.pdf

get_result_file_stream.js on this branch (on main: /convert/web/to/pdf, 91,412 bytes):

[trace] POST v2.convertapi.com/convert/html/to/pdf -> HTTP 200
Result url: https://v2.convertapi.com/d/<file-id>/web-example.pdf
Downloaded data size: 91424

The PDF text: on main and in both runs on this branch, Wikimedia answered ConvertAPI's renderer with its "Too many requests" page (1 page, 62 words), the same page the old web -> pdf got. This does not depend on the converter: in the same hour the same html -> pdf call rendered the article (3 pages, 1,925 words) from the Go, Python, PHP and Ruby examples. The demo URL is being looked at separately.

Seen, not changed: the library itself still picks undocumented converters when no source format is given: any for every zip target and url when the parameters have a Url (src/utils.js, detectFormat). The examples now pass the source format, so they do not depend on it.

CI

The test (Node 20/22/24) jobs ran every example against staging and passed on the first attempt; there get_result_file_stream.js downloaded 286,113 bytes, the full article. The build job fails at "Audit the runtime dependencies": npm audit reports follow-redirects 1.16.0 - 1.16.1 (GHSA-mrwp-f3q8-3g9p), the same failure main has had since 2026-11-07 (https://github.com/ConvertAPI/convertapi-library-node/actions/runs/42359841164). It is not caused by this change.

Same change in the other SDKs

🤖 Generated with Claude Code

The production API spec (https://v2.convertapi.com/info/openapi) has no
web -> pdf and no any -> zip converter. convert_url_to_pdf.js and
get_result_file_stream.js now convert the URL with html -> pdf (same Url
and FileName parameters) and link the html-to-pdf page.
conversion_chaining.js passes 'file' as the source format of the ZIP step:
without a source format the library sends every zip conversion to
any -> zip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the example updates to documented ConvertAPI converters.

No open issues 🎉

What changed in this PR

Updates three Node.js examples to call documented ConvertAPI converters without changing their inputs or output handling. Library format detection remains unchanged.

Changes:

  • Uses html instead of web for both URL-to-PDF examples.
  • Updates their documentation comments to link to the HTML-to-PDF guide.
  • Explicitly passes file as the source format for ZIP conversion in the chaining example.
File Description
examples/​get_result_file_stream.js Uses HTML-to-PDF and updates the guide link.
examples/​convert_url_to_pdf.js Uses HTML-to-PDF and updates the guide link.
examples/​conversion_chaining.js Explicitly selects the documented file-to-ZIP converter.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 9, 2026 14:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the example updates to documented ConvertAPI converters.

No open issues 🎉

Review effort: Balanced

@tomasr78
tomasr78 merged commit 4014125 into main Nov 9, 2026
5 checks passed
@tomasr78
tomasr78 deleted the examples-documented-converters branch November 9, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants